﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.IO;

namespace FXnaInfrastructure
{
    public static class FileService
    {


        public static void ReadGridFile()
        {
 
        }




        /// <summary>
        /// 临时测试用
        /// </summary>
        /// <param name="filePath"></param>
        public static double[,]  ReadTxtRaw(string filePath)
        {
            if (File.Exists(filePath))
            {

                StreamReader objReader = new StreamReader(filePath);
                string sLine = "";
                List<string> LineList = new List<string>();
                while (sLine != null)
                {
                    sLine = objReader.ReadLine();
                    if (sLine != null && !sLine.Equals(""))
                        LineList.Add(sLine);
                }
                objReader.Close();
                

                double[,] data=new double[101,101];
                int i;
                int j;
                double value;


                foreach (string item in LineList)
                {

                    string[] rowoItems= item.Split(new string[]{"\t"},StringSplitOptions.RemoveEmptyEntries);


                    i = (int.Parse( rowoItems[0])+500)/10;
                    j =(int .Parse( rowoItems[1])+500)/10;

                    value =double.Parse( rowoItems[3]);

                    data[i, j] = value;
                   

                }


                return data;


                
            }


            return null;


 
        }


    }
}
